</head>

<body><script type="text/javascript">
 function checkLogin()
 {
     alert('您还没有登陆');
     return false;
 }
  function checkSeach()
 {
     if(document.alike.major.value=='-1'){
         alert('请选择专业');
        return false;
    }
 }
 function Login(){
     window.location.href="?do=index";
 }
 function getOptionMAJOR(){
  $.getJSON("main/message/option.php",{'bval':$("#departid").val()},function(data){
    $("#major").empty();//每次选择前，清空小类的值。
    $("#major").html("<option value='-1'>请选择专业</option>");
    $.each(data, function(index,array){
     var option="<option value='"+array['id']+"'>"+array['name']+"</option>"; 
     $("#major").append(option);
    });                
   }); 
 }
 $(document).ready(function(){
    $("#departid").change(function(){
        getOptionMAJOR();
    });
 });
</script>

        <div class="nav">
            <div class="login"  >
                <?php
                    function getURL($url){
                        if($_SESSION['sid']==''){
                            echo 'href="#" onclick="return checkLogin()" ';
                        }else{
                            echo $url;
                        }
                    }
                    if($_SESSION['sid']=='')
                    {
                ?>
<!--                <form action="" name="loginform" method="post" onkeyup="return form_onkeyup()">
                    <span>用户名:</span><input name="username" id="username" class="input" style="width: 40px" type="text" >
                    <span>密码:</span><input name="pwd" id="password" class="input" style="width: 40px" type="password">
                    <input id="button" name="submit" value="登陆"  type="submit">
                </form>-->
                <div style="padding-top: 2px;padding-left: 20px">
                <span><input  name="submit" value="平台登陆"  type="submit" onclick="return Login()"></span>
                </div>
                <?php
                    }
                    else
                    {
                ?>
                    <span style="padding-left:5px;">欢迎您,<?php echo $_SESSION['username']?>!&nbsp;&nbsp;&nbsp;<a style="text-decoration:underline" href="?do=myaccount">个人中心</a>&nbsp;&nbsp;&nbsp;<a style="text-decoration:underline" href="?do=loginout">退出</a></span>
                <?php
                    }
                ?>
            </div>
            
            <div class="s_search">
                <form method="post" action="?do=showsource" name="alike">
                请选择资源类型:
                <select name="sourcetype">
                    <option value="1">视频</option>
                    <option value="2">课件</option>
                    <option value="3">考试</option>
                    <option value="4">练习</option>
                </select>
                院系:
                <select name="departid" id="departid">
                    <option value="-1">请选择院系</option>
                    <?php
                    $sql ="select * from nettteach_department order by id ";
                    $query =$db->query($sql);
                    while($row =$db->fetch_array($query)){
                    ?>
                    <option value="<?php echo $row['id']?>"><?php echo $row['name']?></option>     
                    <?php
                    }?>
                </select>
                专业:
                <select name="major" id="major">
                   <option value="-1">请选择专业</option>
                </select>
                <input type="text" value="请输入关键字" name ="content" style="width: 100px" onblur="if(this.value=='') this.value='请输入关键字';" 
onfocus="if(this.value=='请输入关键字') this.value='';"  />
                <input type="submit" value="搜索" <?php if($_SESSION['sid']!=''){?>onclick="return checkSeach()"<?php }else{?>onclick="return checkLogin()"<?php }?> name="sub"/>
<!--                <input type="submit" value="高级搜索" onclick="return checkSeach()" name="sub"/>-->
                </form>
            </div>
            
        </div>
        <div class="main">
            <div class="title_2">
                <ul>
                    <li id="lk"><span>最热门网络课程</span></li>
                    <li id="lk"><span>最热门下载课件</span></li>
                    <li id="lk"><span>最热门在线考试/练习</span></li>
                </ul>
            </div>
            <table class="tg">
                <tbody>
                    <tr>
                        <td id="dyt">
                            <table id="ty">
                                <tbody>
                                    <?php 
                                         $sql_course = "select * from nettteach_course where 1=1 order by times desc limit 0,10 ";
                                         $result_course = $db -> query($sql_course);
                                         while($row_course = $db ->fetch_array($result_course))
                                        {
                                    ?>

                                    <tr><td><span>查看次数:&nbsp;<?php echo $row_course['times']?></span><a target=_blank <?php getURL('href="?do=viewcourse&courseid='.$row_course['id'].'"')?>> <?php echo $row_course['title']?></a></td></tr>
                                     <?php }?>
                                </tbody>
                            </table>
                        </td>
                        <td id="dyt">
                            <table id="ty">
                                <tbody>
                                    <?php 
                                         $sql_courseware = "select * from nettteach_courseware where 1=1 order by times desc limit 0,10 ";
                                         $result_courseware = $db -> query($sql_courseware);
                                         while($row_courseware = $db ->fetch_array($result_courseware))
                                        {
                                    ?>
                                    <tr><td><span>下载次数:&nbsp;<?php echo $row_courseware['times']?></span><a <?php getURL('href="?do=leftcourseware&coursewareid='.$row_courseware['id'].'&teacherid='.$row_courseware['writerid'].'"')?>><?php echo $row_courseware['title']?></a></td></tr>
                                     <?php }?>
                                </tbody>
                            </table>
                        </td>
                        <td id="dyt">
                            <table id="ty">
                                <tbody>
                                     <?php 
                                     $sql_exam = "select * from nettteach_exam where 1=1 order by exam_num desc limit 0,10 ";
                                     $result_exam = $db -> query($sql_exam);
                                     while($row_exam = $db ->fetch_array($result_exam))
                                    {
                                    ?>
                                    <tr><td><span>做卷人数:&nbsp;<?php echo $row_exam['exam_num']?></span><a <?php if($_SESSION['sid']==''){ ?> onclick="return checkLogin()" <?php }?> href="?do=<?php if($row_exam['type']==="0") echo 'examinfo';else echo 'exerciseinfo'?>&id=<?php echo $row_exam['exam_id'];?> "><?php echo $row_exam['exam_name']?></a></td></tr>
                                    <?php }?>
                                </tbody>
                            </table>
                        </td>
                    </tr>
                </tbody>
            </table>
            
             <div class="title_2">
                <ul>
                    <li id="lk"><span>最新视频资源</span></li>
                    <li id="lk"><span>最新下载课件</span></li>
                    <li id="lk"><span>最新在线考试/练习</span></li>
                </ul>
            </div>
            <table class="tg">
                <tbody>
                    <tr>
                        <td>
                            <table id="ty">
                                <tbody>
                                    <?php
                                    $sql_videos = "select * from nettteach_videos where state='0' order by intotime desc limit 0,10 ";
                                     $result_videos = $db -> query($sql_videos);
                                     while($row_videos = $db ->fetch_array($result_videos))
                                    {?>
                                    <tr><td><span>[<?php echo date('Y-m-d',$row_videos['intotime'])?>]</span><a <?php getURL('href="?do=viewvideos&video_id='.$row_videos['id'].'&teacherid='.$row_videos['belonger'].'"')?>><?php echo $row_videos['title']?></a></td></tr>
                                    <?php }?>
                                </tbody>
                            </table>
                        </td>
                        <td id="dyt">
                            <table id="ty">
                                <tbody>
                                    <?php
                                     $sql_courseware = "select * from nettteach_courseware where state='0' order by intotime desc limit 0,10 ";
                                     $result_courseware = $db -> query($sql_courseware);
                                     while($row_courseware = $db ->fetch_array($result_courseware))
                                    {?>
                                    <tr><td><span>[<?php echo date('Y-m-d',$row_courseware['intotime'])?>]</span><a <?php getURL('href="?do=leftcourseware&coursewareid='.$row_courseware['id'].'&teacherid='.$row_courseware['writerid'].'"')?>><?php echo $row_courseware['title']?></a></td></tr>
                                    <?php }?>
                                </tbody>
                            </table>
                        </td>
                        <td id="dyt">
                            <table id="ty">
                                <tbody>
                                     <?php 
                                     $sql_exam = "select * from nettteach_exam where 1=1 order by exam_pubtime desc limit 0,10 ";
                                     $result_exam = $db -> query($sql_exam);
                                     while($row_exam = $db ->fetch_array($result_exam))
                                    {
                                    ?>
                                    <tr><td><span>[<?php echo date('Y-m-d',$row_exam['exam_pubtime'])?>]</span><a <?php if($_SESSION['sid']==''){ ?> onclick="return checkLogin()" <?php }?> href="?do=<?php if($row_exam['type']==="0") echo 'examinfo';else echo 'exerciseinfo'?>&id=<?php echo $row_exam['exam_id'];?> "><?php echo $row_exam['exam_name']?></a></td></tr>
                                    <?php }?>
                                </tbody>
                            </table>
                        </td>
                    </tr>
                </tbody>
            </table>          
        </div>